home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / daten / amicheck / utilities / ca2ac.rexx
OS/2 REXX Batch file  |  1994-07-26  |  5KB  |  197 lines

  1. /*
  2.  
  3.    ca2ac -  Convert from CheckbookAccountant printed output
  4.             to AmiCheck import format
  5.  
  6.    Synopsis:
  7.  
  8.      ca2ac <input file> <output file>
  9.  
  10.    Parameters:
  11.  
  12.      <input file>
  13.        a "print" file produced by CheckbookAccountant's print function.
  14.  
  15.      <output file>
  16.        where the converted data should go
  17.  
  18.    Description:
  19.  
  20.      This program converts the output produced via
  21.      CheckbookAccountant's "Print" function to an input suitable for
  22.      importation via AmiCheck's ASCII import function. It completely
  23.      converts the data generated when *only* the "Viewable
  24.      Transactions" option is selected in the "Print" requester.
  25.  
  26.      This means that it doesn't handle budgets at all.     Note that
  27.      CA allows you to split a transaction into several budget
  28.      categories, which AmiCheck doesn't handle (yet).  This makes it
  29.      a bit difficult to do a complete conversion, so don't jettison
  30.      your CBA data files yet!
  31.  
  32.      To generate the input data file:
  33.  
  34.        1. CA should be running with your account opened
  35.  
  36.        2. select the Print option under the File Menu
  37.  
  38.        3. Select the Disk File option in the Print Requester and
  39.           select a file using the resulting File Requester
  40.  
  41.        4. Select *only* the Viewable Transactions option
  42.  
  43.        5. Click on the "Ok..." button.
  44.  
  45.      CA will then create the file you specified in step 3.  It's
  46.      ASCII, so if you want to see what information will be translated,
  47.      take a gander at it with your favorite text viewer.
  48.  
  49.      Then, run it through ca2ac and import the resultant file into
  50.      AmiCheck via the ASCII import function (see the AmiCheck guide for
  51.      more details).
  52.  
  53.      ca2ac does the following category conversions:
  54.  
  55.        *  If the CA entry has the description "Payroll", it makes the
  56.           Category "Salary"
  57.  
  58.  
  59.    Caveats:
  60.  
  61.      There isn't much error checking in this program.
  62.  
  63.      It's pretty simple.
  64.  
  65.      I didn't test the "Taxable" flag conversion, as I don't use it.
  66.      It "should" work.
  67.  
  68.      If the check is voided, CA doesn't put in a date, but AmiCheck
  69.      gets upset if there isn't one.  I hardwired the date for voided
  70.      checks to 01/01/1900
  71.  
  72.  
  73.    Distribution:
  74.  
  75.      This is in the public domain.  Do with it what you will, but don't
  76.      make it write bad checks.
  77.  
  78.    History:
  79.  
  80.      1995-07-20 First public release
  81.  
  82.  
  83.    Author:
  84.  
  85.      Diab Jerius   djerius@cfa.harvard.edu
  86.  
  87. */
  88.  
  89. parse arg file.in file.out .
  90.  
  91. if file.in = '' | file.out = '' then do
  92.   say 'usage: ca2ac <input file> <output file>'
  93.   exit 10
  94. end
  95.  
  96. if ~open( 'input', file.in, 'R' ) then do
  97.   say 'unable to open' file.in
  98.   exit 10
  99. end
  100.  
  101. if ~open( 'output', file.out, 'W' ) then do
  102.   say 'unable to open' file.out
  103.   exit 10
  104. end
  105.  
  106.  
  107. /* skip first four lines */
  108. do for 4
  109.   call readln( 'input' )
  110. end
  111.  
  112. if eof( 'input' ) then do
  113.   say 'premature EOF on' file.in
  114.   exit 10
  115. end
  116.  
  117. /* write out header for AmiCheck import file */
  118. call writeln( 'output', 'Source' file.out )
  119.  
  120. count = 0
  121.  
  122. do while ~eof( 'input' )
  123.  
  124.   line1 = readln( 'input' )
  125.   line2 = readln( 'input' )
  126.  
  127.   if eof( 'input' ) then leave
  128.  
  129.   /* first line is split into 7 sections by column:
  130.      Number, Date, Description, Taxable, Cleared, Sign, Amount
  131.   */
  132.   parse value line1 with 1 number +6 +1 date +10 +2 description +46 +1  taxable 
  133. +1 cleared +1 sign +1 amount .
  134.  
  135.   /* second line is split into two sections by column, memo and running total */
  136.  
  137.   parse value line2 with 20 memo +46 .
  138.  
  139.   call write_entry( number, date, description, taxable, cleared, sign, amount, m
  140. emo )
  141.  
  142.   count = count + 1
  143.  
  144.   /* get rid of last line */
  145.   call readln( 'input' )
  146. end
  147.  
  148. call close( 'input' )
  149. call close( 'output' )
  150.  
  151. say 'wrote' count 'entries'
  152.  
  153. exit 0
  154.  
  155. write_entry: procedure
  156.   parse arg number, date, description, taxable, cleared, sign, amount, memo
  157.  
  158.   number = strip( number )
  159.   description = strip( description )
  160.   memo = strip( memo )
  161.   amount = compress( amount, ',' )
  162.  
  163.   if number = '' then do
  164.     if sign = '+' then number = 'deposit'
  165.     else               number = 'withdrawl'
  166.   end
  167.  
  168.   if cleared = 'C' then state = Y
  169.   else                  state = N
  170.  
  171.   if taxable = 'T' then state = state || 'Y'
  172.   else                  state = state || 'N'
  173.  
  174.   if description = '** VOIDED **' then do
  175.     state = state || 'Y'
  176.     date  = '01/01/1900'
  177.   end
  178.   else state = state || 'N'
  179.  
  180.   category = ''
  181.   if index( 'Payroll', description ) then category = 'Salary'
  182.  
  183.   call writeln( 'output', '' )
  184.   call writeln( 'output', 'type    ' number )
  185.   call writeln( 'output', 'amount  ' amount )
  186.   call writeln( 'output', 'date    ' date )
  187.   call writeln( 'output', 'name    ' description )
  188.   call writeln( 'output', 'addr1   ' )
  189.   call writeln( 'output', 'addr2   ' )
  190.   call writeln( 'output', 'addr3   ' )
  191.   call writeln( 'output', 'memo    ' memo )
  192.   call writeln( 'output', 'state   ' state )
  193.   call writeln( 'output', 'category' '0.00' category )
  194.  
  195.   return
  196.  
  197.